/*
 * @Author: monet hanxu@huaun.com
 * @Date: 2023-09-13 09:52:40
 * @LastEditors: zhangyonggui
 * @LastEditTime: 2023-10-16 14:16:13
 * @FilePath: /h-radar-Attack/store/api.js
 * @Description:
 */

import $axios from '../services/http';
// //创建axios实例
// const axios =$axios.create({})
const state = () => ({
  aip: '/api',
});

const mutations = {};
const actions = {
  // 新增资产标签
  async appendTagsV2({ commit, state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/tagging`,
      data,
    );
  },
  // 清空资产标签
  async emptyTags({ commit, state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/tag-modify/clear-tag-by-selected`,
      data,
    );
  },
  // 删除资产标签
  async deleteTags({ commit, state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/delete-tag`,
      data,
    );
  },

  // 控股公司关系-查询下一级公司
  async getTree({ commit, state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/enterprise-relation/get-target-company-tree-paths`,
      data,
    );
  },
  // 分页获取企业名称-下拉框列表
  async getEnterprise({ commit, state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/enterprise/list-enterprise-for-selected`,
      data,
    );
  },
  // 暴露面导出excel
  async dataExport({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.reportService}${state.aip}/data-export`,
      data,
      {}
    )
  },
  // minioOss文件模板下载接口
  async templateDownload({ state, rootState }, data) {
    return await $axios.get(
      `${rootState.systemService}${state.aip}/mi/oss/template/download?fileName=assetImport.zip`,
      {},
      {
        responseType: 'arraybuffer', 
      }
    )
  },
  // minioOss上传接口
  async uploadFile({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.systemService}${state.aip}/mi/oss/upload`,
      data,
    );
  },
  // 资产模板数据导入
  async assetImport({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}/asset/import`,
      data,
    );
  },
  // 新增|修改所属单位
  async enterpriseSave({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/enterprise-relation/save`,
      data,
    );
  },
  // 批量删除所属单位-左侧树
  async enterpriseRemove({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/enterprise-relation/remove`,
      data,
    );
  },
  // poc列表
  async getPocList({ state, rootState }, data) {
    return await $axios.post(
      `${rootState.resourceService}/operation/poc/queryList`,
      data,
    );
  },
  // 获取所有pocId
  async getPocIds({ state, rootState }) {
    return await $axios.get(
      `${rootState.resourceService}/operation/poc/all/poc-id`,
    );
  },
  // 删除所属公司
  async deleteCompany({ commit, state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/asset/remove-company-of-asset`,
      data,
    );
  },
  // 新增tag标签
  async addTagCondition({ commit, state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/tag-modify/add-tag-by-selected`,
      data,
    );
  },
  // 删除tag标签
  async deleteTagCondition({ commit, state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/tag-modify/remove-tag-by-selected`,
      data,
    );
  },
  // 新增company标签
  async addCompanyCondition({ commit, state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/company-modify/add-company-by-selected`,
      data,
    );
  },
  // 删除company标签
  async deleteCompanyCondition({ commit, state, rootState }, data) {
    return await $axios.post(
      `${rootState.routeServiceV2}${state.aip}/company-modify/remove-company-by-selected`,
      data,
    );
  },
};

export default {
  namespaced: true, // 有命名空间
  state,
  mutations,
  actions,
};
